package com.baidu.yyb.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;


import androidx.recyclerview.widget.RecyclerView;

import com.baidu.yyb.constant.RecycleConstant;
import com.baidu.yyb.holder.BaseHolder;

import java.util.List;

/**
 *
 * @author LiuTong
 */
public class BaseAdapter<T> extends RecyclerView.Adapter<BaseHolder<T>> {

    protected Context context;
    protected List<T> dataList;

    protected BaseAdapter(Context context, List<T> dataList){
        this.context = context;
    }
    @Override
    public BaseHolder onCreateViewHolder( ViewGroup parent, int viewType) {
        View view = null;
        if(viewType == RecycleConstant.RV_DATE_TYPE_NO_DATA){

        }else if(viewType == RecycleConstant.RV_DATE_TYPE_DATA){

        }
        return new BaseHolder(view);
    }

    @Override
    public void onBindViewHolder(BaseHolder holder, int position) {

    }

    @Override
    public int getItemViewType(int position) {
        if(position == 1 ){
            return RecycleConstant.RV_DATE_TYPE_NO_DATA;
        }else if(position <= getItemCount()){
            return RecycleConstant.RV_DATE_TYPE_DATA;
        }else if(position > dataList.size()){
            return RecycleConstant.RV_DATE_TYPE_LOADING;
        }
        return 0;
    }

    @Override
    public int getItemCount() {
        return dataList == null ? 1 : dataList.size() + 1;
    }
}
